<?php
$pageSource = "<?php
require_once(\"database.php\");

$"."linkTableName = $"."_GET['linkTableName'];
$"."childTableName = $"."_GET['childTableName'];
$"."parentId = $"."_GET['id'];


$"."SQLlistQuery = \"
SELECT childTable.* FROM $tableName AS childTable
LEFT JOIN $"."linkTableName AS linkTable ON linkTable.child_id = childTable.id
WHERE linkTable.parent_id IS NULL
   OR NOT EXISTS (SELECT child_id FROM $"."linkTableName WHERE parent_id = $"."parentId AND child_id = childTable.id)
GROUP BY childTable.id
ORDER BY childTable.id\";

// In case the query above fails, you can uncomment below
// to pull all records from the childTable
//$"."SQLlistQuery = \"SELECT * FROM $tableName\";

$"."selectorString = \"\";
//echo $"."SQLlistQuery;
$"."SQLlistResult = $"."db->query($"."SQLlistQuery);
$"."selectorString = \"\";
while ($"."rowArray = $"."db->fetch_array($"."SQLlistResult)) {
$rowTemplate
		
		$"."selectorString .= \"</div>\";
}

echo \"<div class='innerSelector'>$"."selectorString</div>
<button type='button' class='saveSelection'>Save Selection</button>
<button type='button' class='cancelSelection'>Cancel</button>\";
?>";


?>
